import { NativeProvider } from './../providers/native/native';
import { Component } from '@angular/core';
import { Platform, App, Events } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { FingerprintAIO } from '@ionic-native/fingerprint-aio';
import { Global } from '../common/global';
import { BusiProvider } from '../providers/busi/busi';

@Component({
  templateUrl: 'app.html'
})
export class MyApp {
  rootPage:any = "LoginPage";

  constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, private native:NativeProvider, private finger:FingerprintAIO,private busi:BusiProvider,
    public appCtrl: App) {
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault();
      splashScreen.hide();
      native.setStatusStyle();
      this.assertNetwork();
      //this.checkupdate();
      Global.base_url = localStorage.getItem("address");

    });
  }
  checkupdate(){
    this.busi.getVersion().subscribe(
      remoteversion=>{
        this.native.checkupdate(remoteversion.version);
      },
      err=>{
        console.log(err);
      }
    );
  }
    // 检测网络
    assertNetwork() {
      if (!this.native.isConnecting()) {
        this.native.showToast("未检测到网络,请连接网络");
      }
    }
}

